// src/apis/getUserInfo.js
import axiosInstance from "@/apis/axiosInstance";

//获取单个用户信息
export const getUserInfo = async () => {
  try {
    const response = await axiosInstance.get(`/get/userInfo`);
    return response.data;
  } catch (error) {
    throw new Error(error.response ? error.response.data.msg : error.message);
  }
};

//获取用户余额
export const getUserBalance = async () => {
  try{
    const response = await axiosInstance.get(`/get/userBalance`);
    return response.data;
  }catch(error){
    throw new Error(error.response ? error.response.data.msg : error.message)
  }
}

//获取单个用户的所有购物车
export const getUserCartInfo = async () => {
  try{
    const response = await axiosInstance.get(`/get/cart`);
    if (Array.isArray(response)) {
      return {
        code: 1,
        data: response,
        msg: "Success"
      };
    }
    return response.data
  }catch(error){
    throw new Error(error.response ? error.response.data.msg : error.message)
  }
}



